package com.mm.repository;

import com.mm.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    //使用内置的方法,需要在Repository显示的声明
    List<User> findByUsername(String username);
    //自定义方法,注意这里的表名为实体类名
    @Query("select u from User u where username = :username")
    List<User> findByName(@Param("username") String username);
}

